package com.bilibili.juc.set;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.IntFunction;

public class MyTest {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");

//        list.iterator().remove();
        //ctrl+alt+v 快捷键生成变量及类型
        Iterator<String> iterator1 = list.iterator();

        String[] integers = list.stream().toArray(new IntFunction<String[]>() {
            @Override
            public String[] apply(int value) {
                return new String[value];
            }
        });
        Arrays.toString(integers);
        System.out.println("---------------------------");

        String[] arr = {"aaa","bbb","ccc"};
        MyIterator<String> myIterator = new MyIterator(arr);
        Iterator<String> iterator = myIterator.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
    }
}
